#include "display.h"
#include "st7735.h"

/*
0  ~ 20 : boot+app 1/2
20 ~ 36 : progess=100%
36 ~ 60 : FLASH DONE
60 ~ 80 : crc:12345678

*/





void display_clear(uint32_t row)
{
    switch(row)
    {
        case 0: LCD_Fill(0,  0, LCD_H, 20, BACK_COLOR); break;
        case 1: LCD_Fill(0, 20, LCD_H, 36, BACK_COLOR); break;
        case 2: LCD_Fill(0, 36, LCD_H, 60, BACK_COLOR); break;
        case 3: LCD_Fill(0, 60, LCD_H, 80, BACK_COLOR); break;
    }
}



void display_progess(uint32_t progess)
{
    oledPrintf(0,20,ENTIRE,YELLOW,"progess = %d%%", progess);
}

void display_info(const char  *str)
{
    display_clear(2);
    oledString(0, 36, ENTIRE,YELLOW, str);
}


void display_warn(const char  *str)
{
    
}

void display_success(const char  *str)
{
    display_clear(2);
    oledString(0, 36, ENTIRE,GREEN, str);
}

void display_error(const char  *str)
{
    display_clear(2);
    oledString(0, 36, ENTIRE,RED, str);
}

void display_result(bool s, const char  *str)
{
    uint16_t color= (s)? GREEN:RED;
    oledString(0, 36, A2416|G2424|ENTIRE, color, str);
}

void display_result_as_mode(bool s, uint16_t mode, const char  *str)
{
    uint16_t color= (s)? GREEN:RED;
    oledString(0, 36, mode, color, str);
}

void display_check_crc(bool check_value, uint32_t crc)
{
    uint16_t color= (check_value)? GREEN:RED;
    oledPrintf(0, 60, A2012|ENTIRE, color, "crc:%X",crc);
}





